package com.atguigu.crowd.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.atguigu.crowd.entity.Menu;
import com.atguigu.crowd.entity.MenuExample;
import com.atguigu.crowd.mapper.MenuMapper;
import com.atguigu.crowd.service.api.MenuService;

@Service
public class MenuServiceImpl implements MenuService {

	@Autowired
	private MenuMapper menuMapper;

	/**
	 * 查询全部的Menu对象
	 */
	@Override
	public List<Menu> getAll() {
		
		return menuMapper.selectByExample(new MenuExample());
	}

	@Override
	public int saveMenu(Menu menu) {
		return menuMapper.insert(menu);
	}

	@Override
	public int updateMenu(Menu menu){

		//由于pid没有传入，一定要选择使用有选择的更新，保证“pid”z自动不为空，如果不用这个会报错，可以自己多想想
		return menuMapper.updateByPrimaryKeySelective(menu);
	}

	@Override
	public int removeMenu(Integer id) {
		return menuMapper.deleteByPrimaryKey(id);
	}
}





















